

/************************************************************************/
/* 
*/
/************************************************************************/

#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string>

//////////////////////////////////////////////////////////////////////////

#define  _FILE_OFFSET_BITS 64
#include <gbm.h>
#include <EGL/egl.h>
#include <cairo/cairo.h>
#include <linux/input.h>

using namespace std;

class MainWindow
{
protected:
	EGLDisplay						egldpy;
	EGLNativeDisplayType		m_nativeDpy;
	EGLNativeWindowType		m_nativeWindow;

public:
	EGLDisplay display();
	EGLNativeWindowType nativeWindow();;
	void size( int& sw, int& sh );
	void cursorPos( int& x, int& y );

public:
	MainWindow( EGLNativeDisplayType nativeDpy, EGLNativeWindowType nativeWindow );
	virtual ~MainWindow(void);

public:
	static MainWindow& instance();
	static std::string applicationPath();
	static void loadResource( std::string & r, std::string _path );
	static std::string toUtf8(std::string inStr);
	static void toGB2312();

public:
	virtual void onCreate() = 0;
	virtual void paintEvent( ) = 0;
	virtual void keyEvent( int key, int modifier ) = 0;
};

typedef MainWindow * MainWindowPtr;
